//
//  Collider.cpp
//  EidoTron
//
//  Created by Luca Di Franco on 23/06/11.
//  Copyright 2011 Luca Di Franco. All rights reserved.
//

#include "Collider.h"

#include <SDL_opengl.h>

#include "SceneNode.h"
#include "CollisionManager.h"

Collider::Collider(SceneNode* node)
{
	relatedNode = node;
	if (relatedNode->collider != NULL)
	{
		CollisionManager::remove(relatedNode->collider);
		delete relatedNode->collider;
	}
	relatedNode->collider = this;
	collide = false;
}

Collider::~Collider()
{
	relatedNode->collider = NULL;
}

void Collider::render()
{
	float currentColor[4];
	glGetFloatv(GL_CURRENT_COLOR, currentColor);
	glColor3f(1.0f, collide ? 0.0f : 1.0f, collide ? 0.0f : 1.0f);
	renderCollisionSolid();
	glColor4fv(currentColor);
}